package com.timk.goserver.client.ui.screens;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.DockPanel;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Widget;
import com.timk.goserver.client.ui.widgets.CenteredDialog;

/**
 * GraphDialog displays a rating graph for a given user
 * 
 * @author TKington
 *
 */
public class GraphDialog extends CenteredDialog {
	/**
	 * Creates a graph dialog
	 * 
	 * @param userid the user whose graph is being displayed
	 */
	public GraphDialog(String userid) {
		super(MainPanel.instance);
		
		DockPanel panel = new DockPanel();
		
		HTML graph = new HTML("<img src=\"RatingGraph?id=" + userid + "\"/>");
		panel.add(graph, DockPanel.CENTER);
		
		Button closeButton = new Button("Close");
		closeButton.addClickListener(new ClickListener() {
			public void onClick(Widget sender) {
				hide();
			}
		});
		panel.add(closeButton, DockPanel.SOUTH);
		panel.setCellHorizontalAlignment(closeButton,
				HasHorizontalAlignment.ALIGN_CENTER);
		
		setWidget(panel);
	}
}
